package xyz.luxiaoxiang.bean;

import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;

import javax.persistence.*;

/**
 * @author luxx
 */
@Data
@Table
@Entity
public class HotQuestion {

    @JSONField(name = "child_topic_id")
    @Column(name = "child_topic_id")
    private int childTopicId;

    @JSONField(name = "question_id")
    @Column(name = "question_id")
    private int questionId;

    @JSONField(name = "questionName")
    @Column(name = "questionName")
    private String questionName;

    @Id
    @JSONField(name = "answer_id")
    @Column(name = "answer_id")
    private int answerId;

    private String username;

    @Column(columnDefinition = "text")
    private String excerpt;

    @JSONField(name = "is_article")
    @Column(name = "is_article")
    private boolean article;

    public HotArticle getHotArticle() {
        return new HotArticle(childTopicId, questionId, questionName, answerId, username, excerpt);
    }

    public HotQuestion() {
    }

    public HotQuestion(int childTopicId, int questionId, String questionName, int answerId, String username) {
        super();
        this.childTopicId = childTopicId;
        this.questionId = questionId;
        this.questionName = questionName;
        this.answerId = answerId;
        this.username = username;
    }

    public HotQuestion(int childTopicId, int questionId, String questionName, int answerId, String username, String excerpt, boolean article) {
        this.childTopicId = childTopicId;
        this.questionId = questionId;
        this.questionName = questionName;
        this.answerId = answerId;
        this.username = username;
        this.excerpt = excerpt;
        this.article = article;
    }

}
